<html xmlns:th="http://www.thymeleaf.org">
<!-- 弹窗 -->
<div  th:fragment="alertModel" id="myModal" class="modal" style="border-radius:13px;">
  <!-- 弹窗内容 -->
	<div class="modal-content" style="background:#504c4c;">
	  <div class="modal-header" style="padding:0px;text-align:center;background:#504c4c;">
	    <span class="close" style="font-size:3em;color:#fff;width:100%;text-align:right;" onclick="closeModel()">&times;</span>
	    <span id="wxts" style="font-size:1.5em; color:#fff;line-height:25px;">温馨提示</span>
	  </div>
	  <div class="modal-body" id="giftIntr" style="text-align:center;background:#504c4c;">
	  
	  <span id="ct1" style='color:rgb(217, 198, 220);'></span>
	  <input type='hidden' id='giftvotenum' value="" />
	  <span>1</span>
	  <input type='hidden' id='giftNum' maxlength='5' value=1 readonly="readonly"/>
	  <span id="ct2"style='color:rgb(217, 198, 220);'></span><br>
	  <span id="ct3"style='color:rgb(217, 198, 220);'></span>
	  
	  
	  </div>
	  <div class="modal-footer" style="background:#504c4c;">
	    <button id="alertHidden" onclick="closeModel()" style="background:#504c4c;float:left;color:rgba(233, 231, 249, 0.63);">我再想想</button>
	    <button id="alertConfim" style="background:#504c4c;color:white;" onclick="confimSendGift()">确定送出</button>
	  </div>
	</div>
</div>
<!-- 底部导航兰 -->
		<div   th:fragment="bottomButton"  id="buttonChose" style="display:flex;flex-direction:row;position:fixed;bottom:0px;z-index:501;justify-content:space-around;">
			<button th:onclick="toIndex([[${activeId}]])" style="border:0px;background:none;width:30%;color:#333;font-size:1.3em;">首页</button><!-- text-shadow:0 0 4px #FFF,0 -5px 4px #ff3,2px -10px 6px #fd3, -2px -15px 11px #f80, 2px -25px 18px #f20;text-shadow:0 0 4px #FFF,0 -5px 4px #ff3,2px -10px 6px #fd3, -2px -15px 11px #f80, 2px -25px 18px #f20; -->
			<button th:onclick="toActiveInfo([[${activeId}]])" style="border:0px;background:none;width:30%;color:#333;font-size:1.3em;">活动详情</button>
			<button th:onclick="toMediaInfo([[${activeId}]])" style="border:0px;background:none;width:30%;color:#333;font-size:1.3em;">媒体报道</button>
			
			<!-- <button style="border-radius:15px;background:rgba(224, 110, 12, 0.8);width:33%;color:#333;text-shadow:0 0 4px #FFF,0 -5px 4px #ff3,2px -10px 6px #fd3, -2px -15px 11px #f80, 2px -25px 18px #f20;">排行榜</button>-->
		</div>

<footer   th:fragment="footer" style="display:none;'">
	 <!-- jQuery, Bootstrap, jQuery plugins and Custom JS code -->
        <!-- jQuery, Bootstrap, jQuery plugins and Custom JS code -->
        <script src="/js/vendor/jquery-2.2.4.min.js"></script>
        <script src="/js/vendor/bootstrap.min.js"></script>
        <script src="/voteJquery/swiper.min.js"></script>
        <script src="/voteJquery/jquery-ui.min.js"></script>
        <script src="/voteJquery/scroll.js"></script>
        <script src="/voteJquery/jquery.cookie.js"></script>
        <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js "></script>
        <!-- <script src="/voteJquery/jweixin-1.6.0.js"></script> -->
        

        <script type="text/javascript">
         var getUrlParam=function(data){
        	 var reg = new RegExp('(^|&)' + data + '=([^&]*)(&|$)')
        	 var r=window.location.search.substr(1).match(reg);
        	 if(r!=null){
        		 return unescape(r[2]);
        	 }else{
        		 return null;
        	 }
         };
         var getWxCode=function(local){
 			var token = getCookie("token");
 			if(token!=null){
 				return true;
 			}
 			 const code = getUrlParam('code');
 			 if(code==null || code == '' || code=="undefined"){
 				 $.ajax({
 	                 url:"/api/weixin/loginH5",//获取登录授权的访问地址
 	                 type:"POST",
 	                 data:{"redirectUrL":local},
 	                 dataType:'json',
 	                 success:function (data) {
 	                 	if(data.status==1){
 	                 		console.log("dtaa:",data.data)
 	                 		window.location.href=data.data;
 	                 		return;
 	                 	}
 	                 },
 	                 error:function (e) {
 	                     console.log(e);
 	                 }
 	                 ,timeout:function (e) {
 	                     console.log(e);
 	                 }
 	             });
 			 }  
 	      	};
 	 	      var getWxCodeBoss=function(busId){
 	        	 $.ajax({
 	     	        url:"/api/weixin/getWxCodeBoss",//获取登录授权的访问地址
 	     	        type:"POST",
 	     	      	headers: {
	                     "T-Zhkl-Token":getCookie("token")
	                   },
 	     	        data:{"busId":busId},
 	     	        dataType:'json',
 	     	        success:function (data) {
 	     	        	if(data.status==1){
 	     	        		alert(data.text);
 	     	        		window.location.href="/api/vote/goToSuccessPage";
 	     	        	}else{
 	     	        		alert(data.text+"~~有疑问联系官方平台工作人员处理");
 	     	        		window.location.href=window.location.href;
 	     	        	}
 	     	        },
 	     	        error:function (e) {
 	     	            console.log(e);
 	     	        }
 	     	        ,timeout:function (e) {
 	     	            console.log(e);
 	     	        }
 	     	    });
 	         };
 	         
         var getUserInfo=function(code){//,isBoss,busId
        	 $.ajax({
     	        url:"/api/weixin/h5UseCodeLogin",//获取登录授权的访问地址
     	        type:"POST",
     	        data:{"code":code},
     	        dataType:'json',
     	        success:function (data) {
     	        	if(data.status==1){
     	        		setCookie("nickName",data.data.nickName);
     	        		setCookie("imgUrl",data.data.avatar);
     	        		setCookie("token",data.data.token);
     	        	}
     	        },
     	        error:function (e) {
     	            console.log(e);
     	        }
     	        ,timeout:function (e) {
     	            console.log(e);
     	        }
     	    });
         }
        //设置cookie
         var setCookie=function(key,val,expires){//key键 val值 expires时间单位天
        	 if (expires== ""||expires== null) {
        		 expires=365;
        	 }
        	 $.cookie(key,val, { expires: expires }); 
    	  }
        	 //获取cookie
        	var getCookie = function(key){
        		if ($.cookie(key) != ""&&$.cookie(key) != null) {
        			return $.cookie(key);
        		}
        		return null;
        	}
			
			
			 var wxPayService=function(payData){
				   WeixinJSBridge.invoke(
				      'getBrandWCPayRequest', payData,
				      function(res){
				    	  /* console.log(JSON.stringify(res));
				    	  console.log(JSON.stringify(payData));
				    	  
				    	  alert(JSON.stringify(res)); */
				      if(res.err_msg == "get_brand_wcpay_request:ok" ){
				    	  window.location.href=window.location.href;
				      // 使用以上方式判断前端返回,微信团队郑重提示：
				            //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
				      }else if (res.err_msg == "get_brand_wcpay_request:cancel") {
						/* alert("取消献花成功!"); */
						 window.location.href=window.location.href;
					} else if (res.err_msg == "get_brand_wcpay_request:fail") {
						/* alert("支付失败!"); */
						 window.location.href=window.location.href;
					}
				   }); 
				}
				/* if (typeof WeixinJSBridge == "undefined"){
				   if( document.addEventListener ){
				       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
				   }else if (document.attachEvent){
				       document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
				       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
				   }
				}else{
				   onBridgeReady();
				} */
				
				var toIndex=function(activeId){
					window.location.href="/api/vote/h5IndexPage?activeId="+activeId;
				}
				var toActiveInfo=function(activeId){
					window.location.href="/api/vote/h5ActiveDetailPage?activeId="+activeId;
				}
				var toMediaInfo=function(activeId){
					window.location.href="/api/vote/h5MediaPage?activeId="+activeId;
				}
				var ajaxMethod=function(url,requestData){
					$.ajax({
		                 url:url,//获取登录授权的访问地址
		                 headers: {
		                     "T-Zhkl-Token":getCookie("token")
		                   },
		                 type:"POST",
		                 data:requestData,
		                 dataType:'json',
		                 success:function (data) {
		                	 console.log("data::",data)
		                	 var reponData={
             			 			reUrl:"/api/vote/h5GiftIndexPage",
             			 			busId:requestData.busId,
             			 			activeId:requestData.acId
             			 	}
		                	 if(requestData.giftId==0){
		//                		 console.log("status::",data.status)
		                		 if(data.status==1){
				                 		$('#alertHidden').css('display','none');
				                 		$('#alertConfim').attr('onclick','redirectUrl('+JSON.stringify(reponData)+')').text("去看看~");
				                 		$(".modal-footer").css("text-align","center");
				                 		var _html="";
				                 		if(data.text.indexOf("审核通过")>0){
				                 			_html="<span style='color:rgb(217, 198, 220);'>"+data.text+"！送礼物继续支持她(他)吧</span>";
				                 		}else{
				                 			_html="<span style='color:rgb(217, 198, 220);'>投票(评论)成功! 送礼物继续支持她(他)吧</span>";
				                 		}
				        				$("#giftIntr").html(_html);
				        				setCookie("buinessId","",-1);
				        				modal.style.display = "block";
				                 	}else{
				                 		$('#alertHidden').css('display','none');
				                 		$('#alertConfim').attr('onclick','redirectUrl('+JSON.stringify(reponData)+')').text("去看看~");
				                 		$(".modal-footer").css("text-align","center");
				                 		var _html="";
				                 		console.log("data.text::",data.text)
				                 		if(data.text.indexOf("尚未开始")>0){
				                 			_html="<span style='color:rgb(217, 198, 220);'>"+data.text+"! 去看看除了点赞(评论)还有哪些提升渠道</span>";
				                 		}else{
				                 			_html="<span style='color:rgb(217, 198, 220);'>"+data.text+"! 别灰心送礼物页还可以支持(Ta)哦</span>";
				                 		}
				                 		 
				        				$("#giftIntr").html(_html);
				        				setCookie("buinessId","",-1);
				        				modal.style.display = "block";
				                 	}
		                	 }else{
		                		 if(data.status==1){
		                			 var payData={
		                  					'appId':data.data.appId,
		                  					'timeStamp': data.data.timeStamp,
		                        	          'nonceStr': data.data.nonceStr,
		                        	          'package': data.data.package,
		                        	          'signType': data.data.signType,
		                        	          'paySign': data.data.paySign,
		                  			}
		                			 wxPayService(payData);
		                			 /* $('#alertHidden').css('display','none');
				                 		$('#alertConfim').attr('onclick','redirectUrl('+JSON.stringify(reponData)+')').text("看(Ta)的排名~");
				                 		$(".modal-footer").css("text-align","center");
				                 		var _html="<span style='color:rgb(217, 198, 220);'>投票成功!您的支持很给力耶！</span>";
				        				$("#giftIntr").html(_html);
				        				setCookie("buinessId","",-1);
				        				modal.style.display = "block"; */
		                		 }else{
		                			 alert("活动尚未开始,敬请关注...")
		                			 window.location.href=window.location.href;
		                			 /* $('#alertHidden').css('display','none');
				                 		$('#alertConfim').attr('onclick','redirectUrl('+JSON.stringify(reponData)+')').text("再试试~");
				                 		$(".modal-footer").css("text-align","center");
				                 		var _html="<span style='color:rgb(217, 198, 220);'>"+data.text+"!重新礼物支持(Ta)吧</span>";
				        				$("#giftIntr").html(_html);
				        				setCookie("buinessId","",-1);
				        				modal.style.display = "block"; */
		                		 }
		                	 }
		                 },
		                 error:function (e) {
		                     console.log(e);
		                 }
		                 ,timeout:function (e) {
		                     console.log(e);
		                 }
		             });
				};
				// 获取弹窗
				var modal = document.getElementById('myModal');
				//点击关闭确定框
				var closeModel=function(){
					/* $("#giftNum").val(1); */
				
					modal.style.display = "none";
					setCookie("buinessId","",-1);
					window.location.href=window.location.href;
				}
				// 在用户点击其他地方时，关闭弹窗
				window.onclick = function(event) {
				    if (event.target == modal) {
				        /* $("#giftNum").val(1); */
				        modal.style.display = "none";
				        setCookie("buinessId","",-1);
				        window.location.href=window.location.href;
				    }
				   
				}
				var redirectUrl=function(data){
					window.location.href=data.reUrl+"?busId="+data.busId+"&activeId="+data.activeId;
				}
				var endActive=function(activeId){
					$.ajax({
			              url:"checkActiveStatus",
			              type:"POST",
			              data:{activeId:activeId},
			              dataType:'json',
			              success:function (data) {
			                  if(data.status==1){
			                	  return;
			                  }else{
			                	  var _html="";
			                	    $('#alertHidden').css('display','none');
			                 		$(".modal-footer").css("text-align","center");
			                 		if(data.data==2){
			                 			$('#alertConfim').attr('onclick','consoleModel()').text("好滴~");
			                 			_html="<span style='color:rgb(217, 198, 220);'>活动关闭中！敬请关注~~!</span>";
			                 		}else{
			                 			$('#alertConfim').attr('onclick','consoleModel()').text("知道啦~");
			                 			_html="<span style='color:rgb(217, 198, 220);'>本次活动结束！感谢您的大力支持~~!</span>";
			                 		}
			                 		
			        				$("#giftIntr").html(_html);
			        				setCookie("buinessId","",-1);
			        				modal.style.display = "block";
			            			return;
			                  }

			              },
			              error:function (e) {
			                  console.log(e);
			                  $('#alertHidden').css('display','none');
		                 		$('#alertConfim').attr('onclick','consoleModel()').text("知道啦~");
		                 		$(".modal-footer").css("text-align","center");
		                 		var _html="<span style='color:rgb(217, 198, 220);'>"+e+"</span>";
		        				$("#giftIntr").html(_html);
		        				setCookie("buinessId","",-1);
		        				modal.style.display = "block";
		            			return;
			              }
			              ,timeout:function (e) {
			                  $('#alertHidden').css('display','none');
		                 		$('#alertConfim').attr('onclick','consoleModel()').text("知道啦~");
		                 		$(".modal-footer").css("text-align","center");
		                 		var _html="<span style='color:rgb(217, 198, 220);'>"+e+"</span>";
		        				$("#giftIntr").html(_html);
		        				setCookie("buinessId","",-1);
		        				modal.style.display = "block";
		            			return;
			              }
			          });
				}
				var consoleModel=function(){
					window.location.href=window.location.href;
				}
				
			let wxData = '';
			var setWXconfig = function(urlhref,activeId){
				$.ajax({
				    url: "/api/vote/groupConfig",
				    type: "POST",
				    data: {url:urlhref,activeId:activeId},
				    success: function (data) {
				    	resultData=eval("("+data+")");
				    		wxData = {
					            "imgUrl": resultData.data.active.shareImgUrl, //分享图标
					            "title": resultData.data.active.ac_name, //分享标题
					            "desc": resultData.data.active.shareDesc, //分享描述
					            "link": urlhref//分享跳转地址
					        };
				       console.log(wxData) 
				        console.log("dtastatus:"+resultData.status)
				        if (resultData.status==1){
				        	console.log("dstatus:"+resultData.data.appId)
				        	 wx.config({
		                    	    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
		                    	    appId: resultData.data.appId, // 必填，企业号的唯一标识，此处填写企业号corpid
		                    	    timestamp: resultData.data.timestamp, // 必填，生成签名的时间戳
		                    	    nonceStr: resultData.data.nonceStr, // 必填，生成签名的随机串
		                    	    signature:  resultData.data.signature, // 必填，签名，见附录1 
		                    	    jsApiList:[
		                    	    	'updateAppMessageShareData',
		                    	    	'updateTimelineShareData',
						            ]// 必填，需要使用的JS接口列表，所有JS接口列表见附录2'updateAppMessageShareData', 'updateTimelineShareData'
						            //openTagList: ['wx-open-launch-weapp'] // 可选，需要使用的开放标签列表，例如['wx-open-launch-app']wx-open-launch-weapp 指H5跳转小程序wx-open-launch-app 指H5跳转app
		                    	});
				        }
				       
				    },
				    fail: function (res) {
				        console.log("33333:"+res);

				    }
				})
				}
				
			wx.ready(function () {
				wx.updateAppMessageShareData({
			        title: wxData.title,
			        desc: wxData.desc, // 分享描述
			        link: wxData.link,
			        imgUrl: wxData.imgUrl,
			        success: function () {
			　　　　　　//分享成功后的回调
			　　　　 }
			    });
				wx.updateTimelineShareData({
			        title: wxData.title,
			        link: wxData.link,
			        imgUrl: wxData.imgUrl,
			        success: function () { 
			　　　　　　//分享成功后的回调
			　　　　 }
			    });
			});
			wx.error(function(res){
				/* console.log("ressssssssssssss:",res) */
				resultData=eval("("+res+")");
				alert(resultData.errMsg)
				  // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
			});
				
     </script>
    </footer>
    
    